const electron = require('electron');
const ipcMain = electron.ipcMain;


exports.on = function(name,callback){
    ipcMain.on(name,function(event,arg){
        var data = JSON.parse(arg);
        //console.dir(data);
        callback(data,{
            reply:function(rs){
                event.sender.send(data.replycmd,JSON.stringify(rs));
            },
            end:function(rs){
                rs.end = 1;
                event.sender.send(data.replycmd,JSON.stringify(rs));
            }
        });
    })
}